#include "connexion.hpp"
#include <QDebug>

Connexion::Connexion(QWidget * parent) : QWidget(parent)
{
    setWindowTitle("Connection");
    _layout = new QGridLayout(this);
    setLayout(_layout);

    _label = new QLabel("Port", this);
    _port = new QSpinBox(this);
    _button = new QPushButton("Run the server", this);

    _port->setRange(1024, 65535);
    _port->setValue(4242);

    _layout->addWidget(_label, 0, 0, 1, 1, Qt::AlignCenter);
    _layout->addWidget(_port, 0, 1);
    _layout->addWidget(_button, 1, 0, 1, 2);

    connect(_button, SIGNAL(clicked()), this, SLOT(reactClick()));
}

void Connexion::reactClick()
{
    emit connexion(_port->value());
}
